import sys

class Lexer:
    def __init__(self):
        # 定义保留字集合
        self.reserved_words = {'if', 'int', 'for', 'while', 'do', 'return', 'break', 'continue'}
        
        # 定义分隔符集合
        self.delimiters = {',', ';', '{', '}', '(', ')'}  
        
        # 定义运算符集合
        self.operators = {'+', '-', '*', '/', '='}
        
        # 定义关系运算符集合
        self.relational_operators = {'>', '<', '==', '>=', '<=', '!='}
        
        # 初始化标识符表和常数表
        self.identifier_table = {}  # 标识符: 索引
        self.constant_table = {}    # 常数: 索引
        
        # 初始化计数器
        self.identifier_count = 0
        self.constant_count = 0
        
        # 当前行和字符位置
        self.line = ''
        self.pos = 0
        self.line_number = 0
    
    def read_line(self):
        # 从标准输入读取一行
        line = sys.stdin.readline()
        if not line:
            return False
        self.line = line
        self.pos = 0
        self.line_number += 1
        return True
    
    def is_letter(self, c):
        # 判断是否为字母
        return c.isalpha() or c == '_'
    
    def is_digit(self, c):
        # 判断是否为数字
        return c.isdigit()
    
    def skip_whitespace(self):
        # 跳过空格和制表符
        while self.pos < len(self.line) and self.line[self.pos].isspace():
            self.pos += 1
    
    def get_identifier_or_reserved(self):
        # 获取标识符或保留字
        start = self.pos
        while self.pos < len(self.line) and (self.is_letter(self.line[self.pos]) or self.is_digit(self.line[self.pos])):
            self.pos += 1
        
        word = self.line[start:self.pos]
        
        # 检查是否为保留字
        if word in self.reserved_words:
            return (word, 1, 5)  # 保留字种别码为1
        else:
            # 检查是否在标识符表中
            if word not in self.identifier_table:
                self.identifier_count += 1
                self.identifier_table[word] = self.identifier_count
            
            # 注意：根据输出样例，标识符的种别码应该是6，而常数是5
            return (word, 6, self.identifier_table[word])
    
    def get_constant(self):
        # 获取无符号整数
        start = self.pos
        while self.pos < len(self.line) and self.is_digit(self.line[self.pos]):
            self.pos += 1
        
        num = self.line[start:self.pos]
        
        # 检查是否在常数表中
        if num not in self.constant_table:
            self.constant_count += 1
            self.constant_table[num] = self.constant_count
        
        # 注意：根据输出样例，常数的种别码应该是5，而标识符是6
        return (num, 5, self.constant_table[num])
    
    def get_operator(self):
        # 获取运算符或关系运算符，处理超前搜索
        if self.pos + 1 < len(self.line):
            # 检查两个字符的运算符
            double_op = self.line[self.pos:self.pos+2]
            if double_op in self.relational_operators:
                self.pos += 2
                # 根据输出样例，关系运算符种别码为4
                if double_op == '==':
                    return (double_op, 4, 5)
                elif double_op == '>=':
                    return (double_op, 4, 5)
                elif double_op == '<=':
                    return (double_op, 4, 5)
                elif double_op == '!=':
                    return (double_op, 4, 5)
                else:
                    return (double_op, 4, 5)
        
        # 检查单个字符的运算符或分隔符
        single_op = self.line[self.pos]
        self.pos += 1
        
        if single_op in self.operators:
            # 运算符种别码为3
            if single_op == '+':
                return (single_op, 3, 1)
            elif single_op == '-':
                return (single_op, 3, 1)
            elif single_op == '*':
                return (single_op, 3, 1)
            elif single_op == '/':
                return (single_op, 3, 1)
            elif single_op == '=':
                return (single_op, 3, 5)
        elif single_op in self.delimiters:
            # 分隔符种别码为2
            if single_op == ',':
                return (single_op, 2, 1)
            elif single_op == ';':
                return (single_op, 2, 2)
            elif single_op == '{':
                return (single_op, 2, 3)
            elif single_op == '}':
                return (single_op, 2, 4)
            elif single_op == '(':
                return (single_op, 2, 5)
            elif single_op == ')':
                return (single_op, 2, 6)
        elif single_op in self.relational_operators:
            # 关系运算符种别码为4
            if single_op == '>':
                return (single_op, 4, 5)
            elif single_op == '<':
                return (single_op, 4, 5)
        
        # 未识别的字符
        print("Error")
        return None
    
    def tokenize(self):
        # 词法分析主函数
        while self.read_line():
            while self.pos < len(self.line):
                self.skip_whitespace()
                if self.pos >= len(self.line):
                    break
                
                current_char = self.line[self.pos]
                
                if self.is_letter(current_char):
                    # 处理标识符或保留字
                    token = self.get_identifier_or_reserved()
                elif self.is_digit(current_char):
                    # 处理常数
                    token = self.get_constant()
                else:
                    # 处理运算符或分隔符
                    token = self.get_operator()
                
                # 输出token
                if token:
                    print(f"({token[0]},{token[1]},{token[2]})")
        
        print("Anysis End")

def main():
    lexer = Lexer()
    lexer.tokenize()

if __name__ == "__main__":
    main()